module UserCfgHelper
  #得到图片的真实路径
  def get_img_path user_collect,type
    src_arry = []
    small_path = File.join($upload_path,user_collect.img_path,type)
    src_arry = DataFile.traverse_dir(small_path, src_arry)
    index = user_collect.img_index
    @img_path = src_arry[index].gsub($upload_path, $img_path)
  end

  #得到套图分页
  def get_res_array_pagin(res_path,type,pp_num)
    #得到的图片的数组
    src_arry = Array.new
    return_arry = Array.new
    small_path = File.join($upload_path,res_path,type)

    src_arry = DataFile.traverse_dir(small_path, src_arry)
    src_arry.each  do |str|
      return_arry.push str.gsub($upload_path, $img_path)
    end
    if return_arry.size < pp_num.to_i
      pp_num = return_arry.size
    end
    if pp_num.to_i == 0
      pp_num = 2
    end
    @img_arry = return_arry.paginate(:per_page =>pp_num)
  end

  #评论
  def get_comments res_id
    #评论   
    @uc_count =  UserComment.count(:all, :conditions => "res_id = #{res_id}")
  end
 
end
